home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Animation How-To
/
Animation How-to CD.iso
/
PLY
/
CHAPTER3
/
CELL
/
HEXCELL1.BAS
next >
Wrap
BASIC Source File
|
1994-01-01
|
2KB
|
80 lines
' HEXCELL1.BAS
OPEN "hexcell1.pi" FOR OUTPUT AS #1
PRINT #1, "// HEXCELL1.PI"
PRINT #1, "// Growing Hexagonal Cluster that tumbles"
PRINT #1,
PRINT #1, "start_frame 1"
PRINT #1, "end_frame 180"
PRINT #1, "total_frames 180"
PRINT #1,
PRINT #1, "define index frame*360/total_frames"
PRINT #1, "define size 12*frame/total_frames"
PRINT #1, "define pi 3.14159"
PRINT #1, "define rad pi/180"
PRINT #1, "define tumble <index,45*sin(2*index*rad),90*cos(index*rad)>"
PRINT #1,
PRINT #1, "outfile "; CHR$(34); "hex"; CHR$(34)
PRINT #1,
PRINT #1, "include "; CHR$(34); "\ply\colors.inc"; CHR$(34)
PRINT #1,
PRINT #1, "viewpoint {"
PRINT #1, " from rotate(<15,35,-20>, tumble)/12*(size+1)"
PRINT #1, " at <0,0,0>"
PRINT #1, " up <0,1,0>"
PRINT #1, " angle 40"
PRINT #1, " resolution 320,200"
PRINT #1, " aspect 1.333"
PRINT #1, " }"
PRINT #1,
PRINT #1, "background MidnightBlue"
PRINT #1,
PRINT #1, "spot_light <1,0,0>, < 100,0,0>,<0,0,0>,3,5,20"
PRINT #1, "spot_light <0,1,0>, <-100,0,0>,<0,0,0>,3,5,20"
PRINT #1, "spot_light <0,0,1>, < 0, 100,0>,<0,0,0>,3,5,20"
PRINT #1, "spot_light <1,1,0>, < 0,-100,0>,<0,0,0>,3,5,20"
PRINT #1, "spot_light <0,1,1>, < 0,0, 100>,<0,0,0>,3,5,20"
PRINT #1, "spot_light <1,0,1>, < 0,0,-100>,<0,0,0>,3,5,20"
PRINT #1,
PRINT #1, "define pop1 3*frame/30"
PRINT #1, "define pop2 3*sin(3*frame*rad)"
PRINT #1,
PRINT #1, "if (frame < 30) {"
PRINT #1, " object { sphere <0,0,0>,pop1 matte_white }"
PRINT #1, "}"
PRINT #1,
PRINT #1, "if (frame < 60) {"
PRINT #1, " object { sphere <0,0,0>,pop2 matte_white }"
PRINT #1, "}"
PRINT #1,
cel = 8
n = 0
FOR z = -cel TO cel
z1 = z * 1.632993 + 0 ' sqrt(8/3)z
alt1 = 1
IF z MOD 2 = 0 THEN alt1 = 0
FOR y = -cel TO cel
y1 = y * 1.732051 - 1.154701 * alt1 ' sqrt(3)y + 2*sqrt(3)/3
alt2 = 1
IF y MOD 2 = 0 THEN alt2 = 0
FOR x = -cel TO cel
x1 = x * 2 + 1 * alt2 ' 2x + 1 or 2x + 0
IF (x1 ^ 2 + y1 ^ 2 + z1 ^ 2) ^ .5 < 12 THEN
vect$ = "c" + RIGHT$("0000" + LTRIM$(STR$(n)), 4)
PRINT #1, USING "define \ \ <###.#####,###.#####,###.#####>"; vect$; x1; y1; z1
PRINT #1, USING "if ( |\ \| < size) {"; vect$
PRINT #1, USING " object { sphere \ \, 1 matte__white } "; vect$
PRINT #1, "}"
n = n + 1
END IF
NEXT x
NEXT y
NEXT z
CLOSE #1